package br.net.woodstock.tickettoride.client.utils;

import java.security.GeneralSecurityException;

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;

import br.net.woodstock.rockframework.security.crypt.KeyType;
import br.net.woodstock.rockframework.security.util.SecurityUtils;

public abstract class KeyUtils {

	private static final KeyType	KEY_TYPE	= KeyType.DESEDE;

	public static SecretKey newSecretKey() throws GeneralSecurityException {
		KeyGenerator generator = KeyGenerator.getInstance(KeyUtils.KEY_TYPE.getAlgorithm());
		SecretKey secretKey = generator.generateKey();
		return secretKey;
	}

	public static SecretKey loadSecretKey(final byte[] key) {
		return SecurityUtils.getSecretKeyFromFile(key, KeyUtils.KEY_TYPE);
	}

}
